
-- Configure a C/C++ package to use wxWidgets
function configureWxWidgets(package)
    -- Can be something like "--unicode=yes --static=yes --debug=no adv,media"
    additionalWxConfigFlags = "" 

    if (package.kind == "dll") then
        tinsert(package.defines, "WXMAKINGDLL")
    end
    
    tinsert(package.respaths, "$(WXWIN)/include")

    if (target == "gnu") then
        -- Inserts for GNU make the $(shell command) function syntax
        tinsert(package.buildoptions, "$(shell wx-config --cxxflags "..additionalWxConfigFlags..")")
        tinsert(package.linkoptions,  "$(shell wx-config --libs "..additionalWxConfigFlags..")")
    elseif (target == "vs6" or target == "vs2002" or target == "vs2003" or target == "vs2005") then
        -- Inserts for MSVC the output of wx-config directly inside the project
        os.execute("wx-config --cxxflags --compiler=vc "..additionalWxConfigFlags.." > respfile_cxxflags.txt")
        os.execute("wx-config --libs --compiler=vc "..additionalWxConfigFlags.." > respfile_libs.txt")
        cf = io.open("respfile_cxxflags.txt")
        li = io.open("respfile_libs.txt")
        tinsert(package.buildoptions, cf:read("*a"))
        tinsert(package.linkoptions, li:read("*a"))
        io.close(cf)
        io.close(li)
        os.remove("respfile_cxxflags.txt")
        os.remove("respfile_libs.txt")
    else
        -- For all the rest, inserts the backticks `command` syntax
        tinsert(package.buildoptions, "`wx-config --cxxflags "..additionalWxConfigFlags.."`")
        tinsert(package.linkoptions,  "`wx-config --libs "..additionalWxConfigFlags.."`")
    end
end

---------------------------------------------------------------------------------------------------

project.name = "SquidConverter"
project.language = "c++"

package.kind = "winexe"
package.files = { matchfiles(project.name .. "*.*") }
package.links = { "avformat", "avcodec", "avutil" }
package.libpaths = { "ffmpeg/lib" }
package.includepaths = { "ffmpeg/include" }

configureWxWidgets(package)

